conditionally add properties in an object